<template>
  <div>
    <h1>axios再次提炼</h1>
    用户名：<input type="text" v-model="user_name" /><br />
    密码：<input type="text" v-model="password" /><br />
    <button @click="register">注册</button>
  </div>
</template>

<script>
// 参数说明：method: 请求方式  get post
//  url: 地址  ''
//  params: get请求的参数 {}
// data: post请求的参数 {}
// headerType: '' 'form'
import request from "@/untils/request.js";
export default {
  async mounted() {
    let result = await request({
      method: "get",
      url: "/search_info",
    });
    console.log(result);
  },
  data() {
    return {
      user_name: "",
      password: "",
    };
  },
  methods: {
    async register() {
      const user = {
        user_name: this.user_name,
        password: this.password,
      };
      let result = await request({
        method: "post",
        url: "/register",
        data: user,
        headerType: "form",
      });
      console.log(result);
    },
  },
};
</script>

<style lang="scss" scoped>
</style>